﻿using System;
using System.Windows;
using Microsoft.Phone.Controls;

namespace STEM123
{
    /// <summary>
    /// Allows a user to define the term being explained in a presentation.
    /// </summary>
    public partial class CreateTerm : PhoneApplicationPage
    {
        #region Private members

        /// <summary>
        /// Occurs when begin button is clicked.
        /// </summary>
        /// <param name="sender">Button reference.</param>
        /// <param name="e">Event specific arguments.</param>
        private void btnBegin_Click(object sender, RoutedEventArgs e)
        {
            // validate input
            if (string.IsNullOrWhiteSpace(txtTerm.Text.Trim()))
            {
                MessageBox.Show("Please enter the term / idea or concept which you want to explain.");
                txtTerm.Focus();
            }
            else
            {
                // update state for later reference
                ExplainViewModel.Instance.ResetState();
                ExplainViewModel.Instance.Term = txtTerm.Text.Trim();
                
                // navigate to next page
                NavigationService.Navigate(new Uri("/CreateSlides.xaml", UriKind.Relative));
            }
        }

        #endregion

        #region Protected members

        /// <summary>
        /// Occurs when page is navigated to, from some other page.
        /// </summary>
        /// <param name="e">Navigation event arguments.</param>
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.txtTermGuidance.Text = "Enter the term, topic or idea you would like to explain.";

            this.txtContentGuidance.Text = "Remember: " + Environment.NewLine
                + "1. You can explain a concept, term using 1, 2 or 3 slides." + Environment.NewLine
            + "2. Each slide is used to answer one question only." + Environment.NewLine
            + "3. You can use either text, image, audio or video to answer the question in a slide.";

            this.txtTerm.Focus();
        }

        #endregion

        #region Public members

        /// <summary>
        /// Initializes a new instance of CreateTerm.
        /// </summary>
        public CreateTerm()
        {
            InitializeComponent();
        }

        #endregion
    }
}